package com.per.mybootall.es;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

@Component
@EnableScheduling
public class job {
    @Resource
    private RestHighLevelClient restHighLevelClient;


    @Scheduled(cron = "0/10 * * * * ?")
    public void runfirst() throws IOException, InterruptedException {
        ElasticSearchHighUtilsTestThread es=new ElasticSearchHighUtilsTestThread();

        //创建索引
        //es.creatIndex(restHighLevelClient);

        //创建映射
       // es.creatMapping(restHighLevelClient);

        //判断索引是否存在
        //es.testIndexExist(restHighLevelClient);

        //删除索引
      //  es.testDelectIndex(restHighLevelClient);

        //添加文档
         //es.testAddDocument(restHighLevelClient);

        //测试文档是否存在
       // es.testIsExist(restHighLevelClient);

        //获取文档
        //es.testGetDocument(restHighLevelClient);
        //更新文档
        //es.testUpdateRequest(restHighLevelClient);

        //es.testDelectDocument(restHighLevelClient);

        //批量操作
         //es.testBulkRequest(restHighLevelClient);
        //查询
        System.out.println();
        // es.testSearch(restHighLevelClient);
    }
}
